<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
    <script>

        // 给参数b设置默认值，不传该值则使用默认值
        function add(a, b=1) {
            return a + b;
        }

        console.log(add(10));

        // 不定参数
        function multipleParams(...values) {
            console.log(values.length);
        }

        multipleParams(1);

        multipleParams(1,2,3);

        // 箭头函数
        var print = obj => console.log(obj);
        print("hello");

        var sum = (a,b) => a+b;
        console.log(sum(1,2));

        const person = {
            name: 'jack',
            age: 21,
            language: ['java','js','css']
        };

        var hello = obj => console.log('hello, '+obj.name);
        hello(person);

        // 箭头函数+解构表达式
        var hello2 = ({name}) => console.log('hello, '+name);
        hello2(person);

    </script>

</body>
</html>